﻿namespace CodeDDD.Infrastructure.Crosscutting.Seedwork.IoC
{
    /// <summary>
    /// IoC Factory
    /// </summary>
    public static class IoCFactory
    {
        #region Members

        static IContainer _currentContainer = null;
        static IIoCFactory _currentIoCFactory = null;

        #endregion

        #region Public Methods

        /// <summary>
        /// Set the IoC factory to use
        /// </summary>
        /// <param name="logFactory">Log factory to use</param>
        public static void SetCurrent(IIoCFactory ioCFactory)
        {
            _currentIoCFactory = ioCFactory;
            _currentContainer = null;
        }

        public static IContainer GetContainer()
        {
            if (_currentContainer == null)
                _currentContainer = _currentIoCFactory.Create();

            return _currentContainer;
        }

        #endregion
    }
}
